package com.cxw.healthserver.configurer;


import com.cxw.healthserver.interceptor.UserInterceptor;
import com.cxw.healthserver.service.AuthService;
import com.cxw.healthserver.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//注册自定义的拦截器
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    AuthService authService;
    @Autowired
    UserService userService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor(authService,userService))
                .addPathPatterns("/**")
                //排除静态资源
                .excludePathPatterns(
                        "/**/*.html",
                        "/**/*.js",
                        "/**/*.css",
                        "/swagger-ui.html");
    }
}